import xadmin
from company_manage.models import YsbCompanyInfo, BaiduAppCompanyInfo, ClarkiiSeoCompanyInfo, SmsCompanyInfo, AllCompanyInfo


class YsbCompanyInfoAdmin(object):
    list_display = ('id', 'company_name', 'mobile', 'sign_date', 'expire_date', 'service_cycle', 'service_price', 'ad_online_date', 'ad_offline_date')
    list_filter = ['company_name', 'mobile', 'sign_date', 'expire_date', 'service_cycle', 'service_price', 'ad_online_date', 'ad_offline_date']
    list_per_page = 100
    ordering = ['id']
    model_icon = 'fa fa-building-o'

    #list_editable = [‘可以修改的字段’]

    def queryset(self):
        qs = YsbCompanyInfo.objects.exclude(mobile="")
        return qs

    def has_add_permission(self):
        return False

class BaiduAppCompanyInfoAdmin(object):
    list_display = ('id', 'company_name', 'phone_number', 'create_time', 'visit_time', 'app_name')
    list_filter = ['company_name', 'create_time', 'app_name']
    list_per_page = 20
    ordering = ['id']
    model_icon = 'fa fa-building-o'

    #list_editable = [‘可以修改的字段’]

    def queryset(self):
        qs = BaiduAppCompanyInfo.objects.exclude(phone_number="")
        return qs

    def has_add_permission(request, obj=None):
        return False

class ClarkiiSeoCompanyInfoAdmin(object):
    list_display = ('id', 'company', 'mobile', 'start_time', 'end_time', 'email', 'industry', 'mainBussiness')
    list_filter = ['company', 'start_time', 'end_time', 'industry', 'mainBussiness']
    list_per_page = 20
    ordering = ['id']
    model_icon = 'fa fa-building-o'

    #list_editable = [‘可以修改的字段’]

    def queryset(self):
        qs = ClarkiiSeoCompanyInfo.objects.exclude(mobile="")
        return qs

    def has_add_permission(request, obj=None):
        return False

class SmsCompanyInfoAdmin(object):
    list_display = ('id', 'company_name', 'phone', 'url', 'city', 'keyword', 'discover_count', 'discover_time')
    list_filter = ['company_name', 'city', 'phone', 'discover_time']
    list_per_page = 20
    ordering = ['id']
    model_icon = 'fa fa-building-o'

    #list_editable = [‘可以修改的字段’]

    def queryset(self):
        qs = SmsCompanyInfo.objects.exclude(phone="")
        return qs

    def has_add_permission(request, obj=None):
        return False

class AllCompanyInfoAdmin(object):
    list_display = ('id', 'company_name', 'phone', 'source')
    list_filter = ['company_name', 'phone', 'source']
    list_per_page = 20
    ordering = ['id']
    model_icon = 'fa fa-building-o'

    def queryset(self):
        qs = AllCompanyInfo.objects.exclude(phone="")
        return qs

    def has_add_permission(request, obj=None):
        return False

xadmin.site.register(YsbCompanyInfo,YsbCompanyInfoAdmin)
xadmin.site.register(BaiduAppCompanyInfo, BaiduAppCompanyInfoAdmin)
xadmin.site.register(ClarkiiSeoCompanyInfo, ClarkiiSeoCompanyInfoAdmin)
xadmin.site.register(SmsCompanyInfo, SmsCompanyInfoAdmin)
xadmin.site.register(AllCompanyInfo, AllCompanyInfoAdmin)
